package leetcode;

class Sloution {
    public int minArray(int[] numbers) {
        int left = 0;
        int right = numbers.length - 1;

        while (left < right) {
            int mid = left + (right - left) / 2;
            if (numbers[mid] < numbers[right]) {
                right = mid;
            } else if (numbers[mid] > numbers[right]) {
                left = mid + 1;
            } else {
                right -= 1;
            }
        }
        return numbers[left];
    }
}

public class Test4 {
    public static void main(String[] args) {
        Sloution sloution = new Sloution();
        int[] numbers = new int[]{3,4,5,1,2};
        int ret = sloution.minArray(numbers);
        System.out.println(ret);
    }

}
